#
# Makefile template to compile testcase binaries
#
ifndef SRCS
SRCS    := $(wildcard *.c)
endif
OBJS    := $(SRCS:%.c=%.o)

.PHONY:	clean all

LD_FLAGS	+= -latf -ljson
LIB_DEPEND	+= $(HBLIB_PATH)/libatf.a $(HBLIB_PATH)/libjson.a
CFLAGS		+= -g3 -Wall -Werror -I$(TOP_DIR)/inc/atf/

$(ATF_BIN_DIR)/$(TARGET_BIN) : $(TARGET_BIN)
	$(MKDIR) -p $(ATF_BIN_DIR)
	$(CP) $(TARGET_BIN) $(ATF_BIN_DIR)

$(TARGET_BIN):$(OBJS) $(LIB_DEPEND)
	@$(ECHO) Compiling $@, changed dep:$?
	$(CC) -o $@ $(OBJS) $(CFLAGS) $(LD_FLAGS)
	@$(ECHO)  "==========Testcase binary" $@ "Build OK ==========" 

clean:
	@$(RM) $(MAKE_LOG_FILE)
	@$(RM) $(DEPEND_FILE_NAME)
	@$(RM) $(TARGET_BIN)
	@$(RM) $(ATF_BIN_DIR)/$(TARGET_BIN)
	@$(RM) $(OBJS)

$(DEPEND_FILE_NAME):$(SRCS)
	$(RM)	$@
	for x in $(SRCS);	\
	do			\
		$(CC) -MM -MT"$${x%.c}.o" $(CFLAGS) $$x >> $@;\
	done			

include $(SPLINT_MK)

include $(BUILD_MK)

ifneq "$(MAKECMDGOALS)" "clean"
sinclude $(DEPEND_FILE_NAME)
endif

# vim:noet:sw=4:ts=4

